package com.ysq.www.api.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ysq.www.api.order.entity.Order;
import com.ysq.www.api.order.mapper.OrderMapper;
import com.ysq.www.api.order.service.IOrderService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ysq.www.common.result.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 订单表 服务实现类
 * </p>
 *
 * @author dql
 * @since 2020-08-10
 */
@Service
public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements IOrderService {

    @Resource
    private OrderMapper orderMapper;

    @Override
    public ResultMsg selectByPage(Integer pageNumber, Integer pageSize, Integer userId) {
        QueryWrapper<Order> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId).eq("status",0);
        Page<Order> page = new Page<>(pageNumber,pageSize);
        IPage<Order> iPage = orderMapper.selectPage(page, wrapper);
        return ResultMsg.SUCCESS.setNewMsg("分页查询订单成功").setNewData(iPage);
    }
}
